All Questions
Tagged with python-3.xstrings
135 questions
3votes
1answer
98views
Multiline string concatenation
Problem Description Printing the result of adding two numpy arrays together is very ugly. Here we will use these numpy arrays as an example: ...
3votes
2answers
158views
A simple search-and-replace algorithm
In recent times, I've been using the following algorithm repeatedly in different languages (Java, Python, ...) to search and replace strings. I don't like this implementation very much, it's very ...
1vote
1answer
236views
Function that finds the exact number of times a string appears in a text
So I was tasked with providing a function that returns how many exact occurrences of attribute word appear in attribute text. The goal is for the function to be as fast as possible, and I managed to ...
2votes
3answers
146views
Automate the boring stuff with python - Comma Code v2
This is the second version of code reviewed earlier. Comma Code Say you have a list value like this: spam = ['apples', 'bananas', 'tofu', 'cats'] Write a function ...
1vote
3answers
205views
Automate the boring stuff with python - Comma Code
Comma Code Say you have a list value like this: spam = ['apples', 'bananas', 'tofu', 'cats'] Write a function that takes a list value as an argument and returns a ...
4votes
4answers
2kviews
Matching words from a text with a big list of keywords in Python
I implemented the following code to retrieve medication names from a given text (prescription_text in the code). It works by matching words in the text with a list ...
7votes
4answers
445views
Separating a String of Text into Separate Words in Python
Occasionally, we want to do a rudimentary parsing on English text; we separate the text into separate words. ...
3votes
2answers
436views
Add two numbers represented as digit strings
This algorithm adds two numbers digit by digit using their string representations. I am wondering what the time and space complexities of the following algorithm are. In particular, I am wondering ...
-1votes
2answers
71views
Reversing a Python string using [::-1] [closed]
I'm learning how to reverse list and strings. Is there another way of reversing a string other than using [::-1] method? even if the other method is the long route i would much appreciate it ...
1vote
0answers
82views
Application for "Good" and "Bad" word checking
This thread is a continue version of Find match words based on a list of words where I now have added Good word dictionary. What I am trying achieve here is that I want to check if a user has a given ...
1vote
1answer
871views
Adding string to a text file without duplicates
I have a function below, store_in_matchid_file, and it adds certain strings to a .txt file as long as that string doesn't already exist in the file. However that ...
2votes
1answer
191views
follow-up - Checking Nested Bracket Levels in Strings Programming Challenge
A follow-up to this question, this post improves on test case issues. To restate problem parameters, a given string S is considered closed if it: Has a matching ...
3votes
1answer
1kviews
Python function to output a string that is justified to the right
I just solved this exercise from Think Python, 2nd edition: Python provides a built-in function called len that returns the length of a string, so the value of len('allen') is 5. Write a function ...
5votes
1answer
595views
Lingo (word-game) guessing strategy
My friend and I are kind of noobs in Python and are looking for ways to improve. We thought it would be cool if we could get some feedback on the following code. It is for a game named "Lingo&...
1vote
2answers
141views